export default class PressNodeManager {


    public static instance:PressNodeManager = new PressNodeManager();

    private pressNodePool:cc.NodePool;

    private prefab:cc.Prefab = null;


    public init(prefab:cc.Prefab){
        this.prefab = prefab;
        this.pressNodePool = new cc.NodePool();
        for(let i=0; i<50; i++){
            this.pressNodePool.put(cc.instantiate(prefab))
        }
    }

    public createPressNode(){
        let returnNode:cc.Node;
        if(this.pressNodePool.size() > 0){
            returnNode = this.pressNodePool.get();
        }else{
            returnNode = cc.instantiate(this.prefab);
        }
        return returnNode;
    }

    public recoverNode(node:cc.Node){
        this.pressNodePool.put(node)
    }

}